package com.ruoyi.activity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.activity.domain.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;


/**
 * 订单Mapper
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    /**
     * 使用乐观锁更新订单状态
     * @param orderId 订单ID
     * @param oldStatus 原状态（用于乐观锁校验）
     * @param newStatus 新状态
     * @return 更新影响的行数
     */
    @Update("UPDATE `orders` SET status = #{newStatus} " +
            "WHERE id = #{orderId} AND status = #{oldStatus}")
    int updateStatus(@Param("orderId") Long orderId,
                     @Param("oldStatus") Integer oldStatus,
                     @Param("newStatus") Integer newStatus);
} 